using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Gencode.PrsCommon.Data.Common;

namespace Personalplaner
{
    [ToolboxItem(false)]
    public partial class CreateMonthDlg : UserControl, Gencode.Gengui.Forms.ISaveDialog
    {
        public CreateMonthDlg()
        {
            InitializeComponent();
			comboMonth.InitData(Verwaltung.YearID);
        }

		public CreateMonthDlg(int atid)
		{
			InitializeComponent();
			comboMonth.InitData(Verwaltung.YearID);

			comboMonth.SelectedMonthAtID = atid;
		}

        private void comboMonth_SelectedIndexChanged(object sender, EventArgs e)
        {
			txtStunden.Text = comboMonth.SelectedMonthTage.ToString();
        }

		#region ISaveDialog Members

		public void SaveClicked()
		{
			if (txtStunden.Text != "0" && comboMonth.SelectedMonthTypwert > 0)
			{
				CommonData.SaveMonthDays(Verwaltung.YearID, comboMonth.SelectedMonthTypwert, double.Parse(txtStunden.Text));
				comboMonth.RefreshData();
			}
		}

		#endregion

		#region IDialogControl Members

		public bool OKClicked()
		{
			SaveClicked();

			return true;
		}

		public bool CancleClicked()
		{
			return true;
		}

		#endregion
	}
}